<?php

/*
 * This file is the jQuery for showing the div for information of a log.
 * Like if it is disapprove, handles the show and hide of a div on why it was disapproved.
 * 
 * Created by: Peter Agno Jr.
 * Date created: October 22, 2011
 */
?>

// START - JQUERUES FOR SHOWING INFORMATION
            jQuery(".infoIcon").live({
                mouseover: function(mousePtr) {
                    // START - DO THE FOLLOWING DURING HOVER
                    buttonId = this.id;
                    tempSubstr = buttonId.split('_');
                    
                    // MODIFY THE POSITION SO THAT IT IS NOT THAT FAR FROM THE ICON
                    if ( tempSubstr[2] == "fromBase" ) {
                        topValue = mousePtr.pageY - 10;
                        leftValue = mousePtr.pageX - 130;
                    }
                    else {
                        topValue = mousePtr.pageY - 40;
                        leftValue = mousePtr.pageX - 140;
                    }
                    
                    
                    // MODIFY THE CSS POSITION BEFORE SHOWING
                    jQuery("#inviInfoIcn_"+tempSubstr[2]).css({ 'display': 'none', 'top': topValue, 'left': leftValue });
                    
                    // CHECK FOR THE APPROPRIATE IMAGE
                    jQuery("#"+buttonId).attr("src", "images/log/info_blu_ylw.png");
                    
                    // START - AJAX THE NEEDED INFORMATIONS
                    jQuery.ajax({
                        type : 'POST',
                        url : 'ajaxRequests/logMsg.php',
                        dataType : 'json',
                        async : false,
                        data: {
                            logId : tempSubstr[1]
                        },
                        success : function(data){
                            // SET THE INFORMATION IN THE DIV
                            setInfo = data.message;
                            
                            // PUT THE INFORMATION IN THE DIV
                            jQuery("#inviInfoIcn_"+tempSubstr[2]).html(setInfo);
                            jQuery("#inviInfoIcn_"+tempSubstr[2]).show();
                        },
                        error : function() {
                            alert("Error in getting the log information.");
                        }
                    }); // END - AJAX THE NEEDED INFORMATIONS

                    // END - DO THE FOLLOWING DURING HOVER
                }, 
                mouseout: function() {
                    // START - DO THE FOLLOWING DURING NOT HOVER
                    buttonId = this.id;
                    tempSubstr = buttonId.split('_');
                    
                    // CHECK FOR THE APPROPRIATE IMAGE
                    jQuery("#"+buttonId).attr("src", "images/log/info_blu.png");
                    
                    jQuery("#inviInfoIcn_"+tempSubstr[2]).hide();
                    // END - DO THE FOLLOWING DURING NOT HOVER
                }
            }); // END - JQUERUES FOR SHOWING INFORMATION